package com.dgut.shopManage.entity.dto;

import java.util.Date;

import org.springframework.beans.BeanUtils;
import org.springframework.format.annotation.DateTimeFormat;

import com.dgut.common.util.Rent;
import com.dgut.common.util.Stype;
import com.dgut.common.util.Xtype;
import com.dgut.shopManage.entity.Merchant;
import com.dgut.shopManage.entity.Shop;
import com.fasterxml.jackson.annotation.JsonFormat;


public class ShopDTO {
	private Long id;
	private String shopNo;
	private String shopName;
	private String address;
	private Stype stype;
	
	private Long mid;
	private Rent rent;
	private String merchantName;
	private String telephone;
	private Xtype xtype;
	@JsonFormat(pattern = "yyyy/MM/dd HH:mm:ss",timezone = "GMT+8")
	private Date sRentTime;
	@JsonFormat(pattern = "yyyy/MM/dd HH:mm:ss",timezone = "GMT+8")
	private Date eRentTime;
	
	public String getShopNo() {
		return shopNo;
	}


	public void setShopNo(String shopNo) {
		this.shopNo = shopNo;
	}
	public Long getId() {
		return id;
	}


	public void setId(Long id) {
		this.id = id;
	}


	public String getShopName() {
		return shopName;
	}


	public void setShopName(String shopName) {
		this.shopName = shopName;
	}


	public String getAddress() {
		return address;
	}


	public void setAddress(String address) {
		this.address = address;
	}


	public Stype getStype() {
		return stype;
	}


	public void setStype(Stype stype) {
		this.stype = stype;
	}


	public Rent getRent() {
		return rent;
	}


	public void setRent(Rent rent) {
		this.rent = rent;
	}


	public String getMerchantName() {
		return merchantName;
	}


	public void setMerchantName(String merchantName) {
		this.merchantName = merchantName;
	}


	public String getTelephone() {
		return telephone;
	}


	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}


	public Xtype getXtype() {
		return xtype;
	}


	public void setXtype(Xtype xtype) {
		this.xtype = xtype;
	}
	
	public Date getsRentTime() {
		return sRentTime;
	}


	public void setsRentTime(Date sRentTime) {
		this.sRentTime = sRentTime;
	}


	public Date geteRentTime() {
		return eRentTime;
	}

	public void seteRentTime(Date eRentTime) {
		this.eRentTime = eRentTime;
	}
	public Long getMid() {
		return mid;
	}


	public void setMid(Long mid) {
		this.mid = mid;
	}

	public static void entityToDto(Shop shop , ShopDTO dto) {
		BeanUtils.copyProperties(shop, dto);
		Merchant merchant = shop.getMerchant();
		if(merchant!=null) {
			dto.setMid(merchant.getMid());
			dto.setMerchantName(merchant.getMerchantName());
			dto.setTelephone(merchant.getTelephone());
			dto.setXtype(merchant.getXtype());
			dto.setsRentTime(merchant.getsRentTime());
			dto.seteRentTime(merchant.geteRentTime());
			dto.setShopName(merchant.getShopName());
		}
	}
}
